<template>
	<!-- 判断nowPlayingList对象的key值是否不为零，渲染正在上映的第一张图片，
	并设置了一个定时器，点击或者倒计时为0将自动跳转至主页 -->
	<view class="container" v-if="Object.keys(nowPlayingList).length!==0">
	 	 <image :src="nowPlayingList.subjects[0].images.small"/>
		 <view class="start" @click="toPath"> {{time}} 跳过</view> 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: ""
			};
		},
		onReady(){
			this.$store.dispatch("getCity");
			this.timer()
		},
		computed:{
			nowPlayingList(){
				return this.$store.state.nowPlayingList;
			}
		},
		methods:{
			timer() {
				var t = 8
				var timecount = setInterval(() => {
					t --
					this.time = t
					if(t<=0) {
						clearInterval(timecount)
					}
				}, 1000)
			},
			toPath() {
				uni.redirectTo({
					url:"../index/index"
				})
			}		
		},
		watch:{
			'time':function(newVal,oldVal){
				  if(newVal==0){
					this.toPath()
				  }
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		position:fixed;
		top:0;
		bottom:0;
		left:0;
		right:0;
			image{
				width: 100%;
				height: 100%;
			}
			.start{
				position: absolute;
				width: 80px;
				height: 30px;
				top: 70upx;
				right: 5%;
				text-align: center;
				line-height: 30px;
				background:rgba(0,0,0,0.6);
				border-radius: 15px;
				color:#FFFFFF;
			}	
	}
</style>
